<template>
	<view class="add-free-car-by-xlsx">
		 <button @click="req">文件选择</button>
		<!-- <form @submit="handleSubmit">
			<button form-type="submit" class="create-btn">选择</button>
			  <button @click="open">文件选择</button>
		</form>
		<jonej-xlsxAnalysis ref="xlsxAnalysis"></jonej-xlsxAnalysis> -->
	</view>
</template>
<script>
	 // var AfDocument = uni.requireNativePlugin("Aq-ChooseFile");
	export default {
		data() {
			return {
				form: {
					companey: '中心',
					license: '鄂B8R713',
					startTime: '2024年6月1',
					endTime: '2024年6月30',
					entire: '黄石',
					destination: '散花',
					publicTime: '2024年5月10'
				}
			}
		},
		onLoad() {

		},
		methods: {
			req(){
				uni.request({
				    url: 'https://jsonplaceholder.typicode.com/todos/1', //仅为示例，并非真实接口地址。
				    data: {
				        text: 'uni.request'
				    },
				    header: {
				        'custom-header': 'hello' //自定义请求头信息
				    },
				    success: (res) => {
				        console.log(res.data);
				        this.text = 'request success';
				    }
				});
			},
			open(){
			    AfDocument.openMode({
			        size: '10', //选择总数量
			        paths:['/storage/emulated/0/Download','/storage/emulated/0/A',],   //自定义选择目录
			        isDown:true,//是否下钻（true 筛选当前目录以下的所有文件，fales 只筛选当前目录文件） 
			        types:[{
			            name:'文档',
			            value:["doc","wps","docx","xls","xlsx","pdf"]
			        },{
			            name:'视频',
			            value:["mp4"] 
			        },{
			            name:'音乐',
			            value:['mp3','flac'] 
			        },{
			            name:'图片',
			            value:['jpg','png'] 
			        }]
			    },(res)=>{
			        this.data = JSON.stringify(res);
			    })
			},
			handleSubmit() {
				// const images = ref < string[] > ([]);
				this.$refs.xlsxAnalysis.chooseFile({
					count: 6, //默认100
					extension: ['.xls', '.xlsx'],
					success: function(res) {
						console.log(JSON.stringify(res.tempFilePaths));
					}
				})
			}
		}
	}
</script>

<style>
	.add-free-car {
		/* padding: 15px; */
	}

	.uni-column {
		border-bottom: 1px solid #dfdfdf;
		margin-bottom: 6px;
	}

	.label {
		margin: 0 15px;
		color: #666;
	}

	.uni-input {
		padding: 4px 15px;
		background-color: #fff;
		height: 30px;
		line-height: 30px;
	}

	.create-btn {
		margin: 20px 15px;
		background-color: darkorange;
		color: #fff;
	}
</style>